package com.yjhb.android.sbz.adapter;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.BiddingUser;
import com.yjhb.android.sbz.tool.Tool;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;
import com.jojo.android.zxlib.tool.ZxTimeTool;
import com.jojo.android.zxlib.view.CircleImageView;

/**
 * 创建者 zx
 * 创建时间 2020/12/8 15:55
 */
public class BiddingAdapter extends BaseRecyclerAdapter<BiddingAdapter.BiddingHolder, BiddingUser> {
    private final String TAG = "BiddingAdapter";

    public BiddingAdapter(Context context) {
        super(context);
    }

    @Override
    protected BiddingHolder getHolder(View v) {
        return new BiddingHolder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_bidding;
    }


    @Override
    public void onBindViewHolder(@NonNull BiddingHolder biddingHolder, int i) {
        Glide.with(context).load(entity.getAvatar()).apply(new RequestOptions().placeholder(R.mipmap.test_head)).into(biddingHolder.head_iv);
        biddingHolder.nickname_tv.setText(entity.getNickName());
        biddingHolder.time_tv.setText("竞价时间："+ZxTimeTool.getDate(entity.getCreateTime().getTime(),"yyyy-MM-dd HH:mm"));
        biddingHolder.bid_tv.setText("¥" + entity.getMoney().setScale(2));
        biddingHolder.label1.setText(Tool.idTransformString(entity.getCategoryId()));
        biddingHolder.label2.setText(entity.getName());
    }

    class BiddingHolder extends RecyclerView.ViewHolder {
        CircleImageView head_iv;
        TextView nickname_tv;
        TextView time_tv;
        TextView bid_tv;
        TextView label1;
        TextView label2;

        public BiddingHolder(@NonNull View itemView) {
            super(itemView);
            head_iv = itemView.findViewById(R.id.head_iv);
            nickname_tv = itemView.findViewById(R.id.nickname_tv);
            time_tv = itemView.findViewById(R.id.time_tv);
            bid_tv = itemView.findViewById(R.id.bid_tv);
            label1 = itemView.findViewById(R.id.label1);
            label2 = itemView.findViewById(R.id.label2);
        }
    }

}
